package org.freespace.config;

import cn.hutool.json.ObjectMapper;
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericToStringSerializer;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.session.data.redis.config.ConfigureRedisAction;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

@Configuration
//@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 3600)
public class RedisConfig {
//    @Bean
//    public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
//        RedisTemplate<String, String> template = new RedisTemplate<>();
//        template.setConnectionFactory(factory);
//
//        GenericFastJsonRedisSerializer genericFastJsonRedisSerializer = new GenericFastJsonRedisSerializer();
//        // key采用String的序列化方式
//        template.setKeySerializer(new GenericToStringSerializer<>(Object.class));
//        // hash的key也采用String的序列化方式
//        template.setHashKeySerializer(new GenericToStringSerializer<>(Object.class));
//        // value序列化方式采用jackson
//        template.setValueSerializer(genericFastJsonRedisSerializer);
//        // hash的value序列化方式采用jackson
//        template.setHashValueSerializer(genericFastJsonRedisSerializer);
//        template.setEnableTransactionSupport(false);
//        template.afterPropertiesSet();
//        return template;
//    }
//
//    @Bean
//    public ConfigureRedisAction configureRedisAction() {
//        return ConfigureRedisAction.NO_OP;
//    }
}